package xin.alum.aim.coder;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.protobuf.ProtobufDecoder;
import lombok.SneakyThrows;
import xin.alum.aim.model.Aim;

import java.util.List;

/**
 * Protobuf 协议转换
 *
 * @author Alum(alum @ live.cn)
 * @date 2021/8/5 17:05
 */
public class LoginDecoder extends ProtobufDecoder {

    public LoginDecoder() {
        super(Aim.Login.getDefaultInstance());
    }

    @SneakyThrows
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> list) {
        ctx.pipeline().remove(this);
        super.decode(ctx, in, list);
    }
}
